package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.RoadSignAuditService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/4/9.
 */
@Controller
@RequestMapping("/rds_roadSignAudit")
public class RoadSignAuditController {
    @Resource
    private RoadSignAuditService roadSignAuditService;

    @RequestMapping("/getRoadPoleAudit4DT")
    @ResponseBody
    public DTResponseDto getRoadPoleAudit4DT(DTRequestDto dtRequestDto, Integer orgId, String actorIds) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = roadSignAuditService.getRoadPoleAudit4DT(dtRequestDto, orgId, actorIds);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/auditRoadPole")
    @ResponseBody
    public JsonMsgDto auditRoadPole(Integer roadPoleIds, Integer flag) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadSignAuditService.auditRoadPole(roadPoleIds, flag));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }


    @RequestMapping("/getRoadSignAudit4DT")
    @ResponseBody
    public DTResponseDto getRoadSignAudit4DT(DTRequestDto dtRequestDto,
                                             Integer roadPoleId) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = roadSignAuditService.getRoadSignAudit4DT(dtRequestDto, roadPoleId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/auditRoadPoleSign")
    @ResponseBody
    public JsonMsgDto auditRoadPoleSign(String roadPoleId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadSignAuditService.auditRoadPoleSign(roadPoleId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/auditRoadSign")
    @ResponseBody
    public JsonMsgDto auditRoadSign(Integer roadSignId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadSignAuditService.auditRoadSign(roadSignId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/getRoadSignAuditCount")
    @ResponseBody
    public JsonMsgDto getRoadSignAuditCount(Integer orgId, Integer actorId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setIsSuccess(true);
            jsonMsgDto.setJsonData(roadSignAuditService.getRoadSignAuditCount(orgId, actorId));
        } catch (Exception e) {
            jsonMsgDto.setIsSuccess(false);
            e.printStackTrace();
        }
        return jsonMsgDto;
    }
}
